!
!      ***********************************************************
!      *     COMPUTATION OF AN EPHEMERIS OF PHOBOS AND DEIMOS    *
!      *              FROM ESAPHO AND ESADE THEORIES             *
!      *     (MICHELLE CHAPRONT-TOUZE, OBSERVATOIRE DE PARIS)    *
!      ***********************************************************
!      * Constants from (Chapront-Touze, 1990,                   *
!      *         Astron. Astrophys., 240, 159, table 8)          *
!      * Phobos' inertial parameters from (Borderies and Yoder,  *
!      *         1990, Astron. Astrophys., 233, 235)             *
!      ***********************************************************
!      *                 List of subroutines                     *
!      * EPHOB : computation of position and velocity of Phobos  *
!      *         in various reference frames                     *
!      * EDEIM : computation of position and velocity of Deimos  *
!      *         in various reference frames                     *
!      * Subroutines called by EPHOB and EDEIM:                  *
!      * CAL   : computation of position and velocity of Phobos  *
!      *         in the reference frame of the theories          *
!      * CALD  : computation of position and velocity of Deimos  *
!      *         in the reference frame of the theories          *
!      * REF   : rotation of the reference frame of the theories *
!      *         onto the FK5 reference frame                    *
!      * REF50 : rotation of the reference frame of the theories *
!      *         onto the FK4 reference frame                    *
!      * LEC   : loading ESAPHO series, and new constants in     *
!      *         the coefficients and in the mean motions        *
!      * LECD  : loading ESADE series, and new constants in      *
!      *         the coefficients and in the mean motions        *
!      ***********************************************************
!
!      This main stands as an example for use of subroutines
!      EPHOB and EDEIM.
!      It computes, for two Julian dates (DJ2447558.5 and DJ2451515.0),
!      the rectangular coordinates of Phobos and Deimos in three 
!      reference frames (reference frame of the theories, FK4 and FK5)
!
       implicit double precision (a-h,o-z)
!
       dimension x(3),v(3)
!
       dj=2447558.5d0
       pas=3986.5d0
       npas=2
       write (*,1001)
!
       do i=1,npas
          call EPHOB (dj,x,v,1)
          write (*,901)
          write (*,1002) dj,x,v
          call EPHOB (dj,x,v,2)
          write (*,902)
          write (*,1002) dj,x,v
          call EPHOB (dj,x,v,3)
          write (*,903)
          write (*,1002) dj,x,v
          call EDEIM (dj,x,v,1)
          write (*,801)
          write (*,1002) dj,x,v
          call EDEIM (dj,x,v,2)
          write (*,802)
          write (*,1002) dj,x,v
          call EDEIM (dj,x,v,3)
          write (*,803)
          write (*,1002) dj,x,v
          dj=dj+pas
          write (*,*)
       enddo
c     
1001   format (/1x,'Martian satellites : ESAPHO and ESADE theories'/1x,
     +         'Rectangular coordinates referred to Mars barycenter') 
1002   format (1x,f14.6,2x,3(1x,f9.2),3x,3(1x,f9.6))
!
901    format (/,1x,'PHOBOS - Reference frame of the theories ',
     +        ' [JED, Position (km), Velocity (km/s)]')
902    format (/,1x,'PHOBOS - Reference frame of FK4          ',
     +        ' [JED, Position (km), Velocity (km/s)]')
903    format (/,1x,'PHOBOS - Reference frame of FK5          ',
     +        ' [JED, Position (km), Velocity (km/s)]')
C     
801    format (/,1x,'DEIMOS - Reference frame of the theories ',
     +        ' [JED, Position (km), Velocity (km/s)]')
802    format (/,1x,'DEIMOS - Reference frame of FK4          ',
     +        ' [JED, Position (km), Velocity (km/s)]')
803    format (/,1x,'DEIMOS - Reference frame of FK5          ',
     +        ' [JED, Position (km), Velocity (km/s)]')
!
       stop
       end
!
!
!
       BLOCK DATA
!      ****************************************************************
!      * Description of the commons for ESAPHO theory                 *
!      * ep1 : dnu (deg/day), dgam, de = corrections to the mean      *
!      *       elements nu, gamma, e of ESAPHO theory                 *
!      *       lg, h, pi (deg) = mean mean longitude, mean longitudes *
!      *       du node and pericentre for Phobos in J2000.0           *
!      * ep2 : coefficient of t**2 in the mean longitude of Phobos    *
!      * ep3 : parameters fixing Mars' position in degree and         *
!      *       correction to Mars' precession of ESAPHO in deg/day    *
!      * ep4 : number of terms in the series for position and         *
!      *       velocity of Phobos (except for perturbations by        *
!      *       Deimos and planets)                                    *
!      ****************************************************************
!      * Description of the commons for ESADE theory                  *
!      * ed1 : dnu (deg/day), dgam, de = corrections to the mean      *
!      *       elements nu, gamma, e of ESADE theory                  *
!      *       lg, h, pi (deg) = mean mean longitude, mean longitudes *
!      *       du node and pericentre for Deimos in J2000.0           *
!      * ed2 : coefficient of t**2 in the mean longitude of Deimos    *
!      * ed4 : number of terms in the series for position and         *
!      *       velocity of Deimos                                     *
!      ****************************************************************
!
       implicit double precision(a-h,o-z)
!
       dimension nb(3),nbv(3),pm(3),al(3)
       dimension nbd(3),nbvd(3),dm(3),ald(3)
!
       common/ep1/pm,al
       common/ep2/accep
       common/ep3/psi0,pipet,alm,dp
       common/ep4/nb,nbv
       common/ed1/dm,ald
       common/ed2/acced
       common/ed4/nbd,nbvd
!
       data nb/27,27,10/
       data nbv/32,32,12/
       data psi0/208.5619d0/
       data pipet/71.0053d0/
       data alm/19.3730d0/
       data dp/-0.181103d-6/
       data pm/0.4994d-3,-0.341d-3,0.146d-3/
       data al/171.9160d0,125.88d0,342.91d0/
       data accep/0.9518d-8/
       data nbd/37,38,25/
       data nbvd/27,27,16/
       data dm/-0.333d-4,0.103d-3,-0.221d-3/
       data ald/215.2172d0,11.20d0,224.01d0/
       data acced/-0.377d-9/
!
       end
!
!
!
       subroutine EPHOB (dj,x,v,ir)
!      **************************************************************
!      * Computation of position and velocity of Phobos in various  *
!      *          reference frames                                  *
!      * Input :  dj = Julian ephemeris date                        *
!      *          ir = 1 for the reference frame of the theories,   *
!      *             = 2 for the FK4 reference frame,               *
!      *             = 3 for the FK5 reference frame                *
!      * Output : position x(3) and velocity v(3) of Phobos in the  *
!      *          reference frame fixed by ir, units = km and  km/s *
!      **************************************************************
!
       implicit double precision (a-h,o-z)
!
       dimension x(3),v(3),xp(3),vp(3),c(3,3),dc(3,3)
!
       data kle/1/
       data d2000/2451545.0d0/
       data day/86400.0d0/
!
       if (kle.eq.1) then
          call LEC
          kle=2
       endif
!
       t=dj-d2000
       call CAL (t,xp,vp)
!
       if (ir.eq.1) then
          do i=1,3
             x(i)=xp(i)
             v(i)=vp(i)/day
          enddo
          return
       endif
!
       if (ir.eq.2) then
          call REF50 (t,c,dc)
       else
          call REF (t,c,dc)
       endif
!
       do i=1,3
          w=0
          wp=0
          do   k=1,3
             w=w+c(i,k)*xp(k)
             wp=wp+c(i,k)*vp(k)+dc(i,k)*xp(k)
          enddo
          x(i)=w
          v(i)=wp/day
       enddo
!
       return
       end
!
!
!
       subroutine EDEIM (dj,x,v,ir)
!      **************************************************************
!      * Computation of position and velocity of Deimos in various  *
!      *          reference frames                                  *
!      * Input :  dj = Julian ephemeris date                        *
!      *          ir = 1 for the reference frame of the theories,   *
!      *             = 2 for the FK4 reference frame,               *
!      *             = 3 for the FK5 reference frame                *
!      * Output : position x(3) and velocity v(3) of Deimos in the  *
!      *          reference frame fixed by ir, units = km and km/s  *
!      **************************************************************
!
       implicit double precision (a-h,o-z)
!
       dimension x(3),v(3),xp(3),vp(3),c(3,3),dc(3,3)
!
       data kle/1/
       data d2000/2451545.0d0/
       data day/86400.0d0/
!
       if (kle.eq.1) then
          call LECD
          kle=2
       endif
!
       t=dj-d2000
       call CALD (t,xp,vp)
!
       if (ir.eq.1) then
          do i=1,3
             x(i)=xp(i)
             v(i)=vp(i)/day
          enddo
          return
       endif
!
       if (ir.eq.2) then
          call REF50 (t,c,dc)
       else
          call REF (t,c,dc)
       endif
!
       do i=1,3
          w=0
          wp=0
          do k=1,3
             w=w+c(i,k)*xp(k)
             wp=wp+c(i,k)*vp(k)+dc(i,k)*xp(k)
          enddo
          x(i)=w
          v(i)=wp/day
       enddo
!
       return
       end
!
!
!
       subroutine CAL (t,x,v)
!      *************************************************************
!      * Computation of position and velocity of Phobos            *
!      *          in the reference frame of the theories           *
!      * Input  : t = ephemeris time in days reckoned from J2000.0 *
!      * Output : position x(3) in km and velocity v(3) in km/day  *
!      *************************************************************
!
       implicit double precision (a-h,o-z)
!
       parameter(id=31,idv=36)
!
       dimension x(3),v(3)
       dimension nb(3),nbv(3)
       dimension arg(id,3),freq(id,3),cs(id,3),cc(id,3),
     +           freq2(id,3)
       dimension argv(idv,3),freqv(idv,3),cvs(idv,3),cvc(idv,3),
     +           frev2(idv,3)
!
       common/ep5/arg,freq,cs,cc,freq2,
     +            argv,freqv,cvs,cvc,frev2
       common/ep4/nb,nbv
       common/ep2/accep
!
       deg=3600.d0/206264.8062470964d0
       t2=t*t*accep*deg
!
       do i=1,3
          jmax=nb(i)
          if (i.ne.3) jmax=jmax+4
          xw=0
          do j=1,jmax
             a=arg(j,i)+freq(j,i)*t+freq2(j,i)*t2
             sa=sin(a)
             ca=cos(a)
             xw=xw+cs(j,i)*sa+cc(j,i)*ca
          enddo
          x(i)=xw
       enddo
!
       do i=1,3
          jmax=nbv(i)
          if (i.ne.3) jmax=jmax+4
          xw=0
          do j=1,jmax
             a=argv(j,i)+freqv(j,i)*t+frev2(j,i)*t2
             sa=sin(a)
             ca=cos(a)
             xw=xw+cvs(j,i)*sa+cvc(j,i)*ca
          enddo
          v(i)=xw
       enddo
!
       return
       end
!
!
!
       subroutine CALD (t,x,v)
!      *************************************************************
!      * Computation of position and velocity of Deimos            *
!      *          in the reference frame of the theories           *
!      * Input :  t = ephemeris time in days reckoned from J2000.0 *
!      * Output : position x(3) in km and velocity v(3) in km/day  *
!      *************************************************************
!
       implicit double precision (a-h,o-z)
!
       parameter(id=38,idv=27)
!
       dimension x(3),v(3)
       dimension nb(3),nbv(3)
       dimension arg(id,3),freq(id,3),cs(id,3),cc(id,3),
     +           freq2(id,3)
       dimension argv(idv,3),freqv(idv,3),cvs(idv,3),cvc(idv,3),
     +           frev2(idv,3)
!
       common/ed5/arg,freq,cs,cc,freq2,
     +        argv,freqv,cvs,cvc,frev2
       common/ed4/nb,nbv
       common/ed2/accep
!
       deg=3600.d0/206264.8062470964d0
       t2=t*t*accep*deg
!
       do i=1,3
          jmax=nb(i)
          xw=0
          do j=1,jmax
             a=arg(j,i)+freq(j,i)*t+freq2(j,i)*t2
             sa=sin(a)
             ca=cos(a)
             xw=xw+cs(j,i)*sa+cc(j,i)*ca
          enddo
          x(i)=xw
       enddo
!
       do i=1,3
          jmax=nbv(i)
          xw=0
          do j=1,jmax
             a=argv(j,i)+freqv(j,i)*t+frev2(j,i)*t2
             sa=sin(a)
             ca=cos(a)
             xw=xw+cvs(j,i)*sa+cvc(j,i)*ca
          enddo
          v(i)=xw
       enddo
!
       return
       end
!
!
!
       subroutine REF (t,c,dc)
!      *************************************************************
!      * Rotation of the reference frame of the theories onto      *
!      *          the FK5 reference frame                          *
!      * Input  : t = ephemeris time in days reckoned from J2000.0 *
!      * Output : c(3,3)  = rotation matrix                        *
!      *          dc(3,3) = derivative of the rotation matrix      *
!      *************************************************************
!
       implicit double precision(a-h,o-z)
!
       dimension ar(3,3),am(3,3),g(3,3),c(3,3),d(3,3)
       dimension arp(3,3),amp(3,3),dc(3,3),dp(3,3)
!
       data g/ 1.000000000000d0,-0.000000479966d0,0.000000000000d0,       edyfk5
     1         0.000000440360d0, 0.917482137087d0, 0.397776982902d0,      edyfk5
     2        -0.000000190919d0,-0.397776982902d0, 0.917482137087d0/      edyfk5
!
       tm=t/365250.d0
       rad=1.d0/206264.8062470964d0
       deg=3600*rad
!
       ah=178409.13618d0*rad+tm*(-0.5149158068948755d-1
     +    +tm*(-0.1117775392103901d-2-0.3427183852553758d-4*tm))
       gam=0.1614120767052974d-1+tm*(-0.710928404247926d-3
     +    +tm*(-0.1968131454406586d-4-0.2505007528551377d-6*tm))
       tet=(35.496817571d0+2.507593d-6*t)*deg
!
       ahp=(-0.5149158068948755d-1
     +     +tm*(-0.1117775392103901d-2*2
     +     -0.3427183852553758d-4*3*tm))/365250.d0
       gamp=(-0.710928404247926d-3
     +     +tm*(-0.1968131454406586d-4*2
     +     -0.2505007528551377d-6*3*tm))/365250.d0
       tetp=2.507593d-6*deg
       thp=ahp+tetp
       ggp=4*gam*gamp
!
       csh=cos(ah)
       snh=sin(ah)
       cst=cos(tet)
       snt=sin(tet)
       csth=csh*cst-snh*snt
       snth=snt*csh+snh*cst
       gm2=gam*gam
       rac=sqrt(1-gm2)
       gm2=2*gm2
!
       am(1,1)=csth+gm2*snh*snt
       am(1,2)=-snth+gm2*snh*cst
       am(2,1)=snth-gm2*csh*snt
       am(2,2)=csth-gm2*csh*cst
       coef=2*gam*rac
       am(1,3)=coef*snh
       am(2,3)=-coef*csh
       am(3,1)=coef*snt
       am(3,2)=coef*cst
       am(3,3)=1-gm2
!
       amp(1,1)=-thp*snth+ggp*snh*snt+gm2*(ahp*csh*snt+tetp*snh*cst)
       amp(1,2)=-thp*csth+ggp*snh*cst+gm2*(ahp*csh*cst-tetp*snh*snt)
       amp(2,1)=thp*csth-ggp*csh*snt+gm2*(ahp*snh*snt-tetp*csh*cst)
       amp(2,2)=-thp*snth-ggp*csh*cst+gm2*(ahp*snh*cst+tetp*csh*snt)
       coefp=2*gamp*(1-gm2)/rac
       amp(1,3)=coef*ahp*csh+coefp*snh
       amp(2,3)=coef*ahp*snh-coefp*csh
       amp(3,1)=coef*tetp*cst+coefp*snt
       amp(3,2)=-coef*tetp*snt+coefp*cst
       amp(3,3)=-4*gam*gamp
!
       q=(25.192028020d0+3.269878d-7*t)*deg
       qp=3.269878d-7*deg
       csq=cos(q)
       snq=sin(q)
!
       ar(1,1)=1
       do i=2,3
          ar(1,i)=0
          ar(i,1)=0
       enddo
       ar(2,2)=csq
       ar(2,3)=-snq
       ar(3,2)=snq
       ar(3,3)=csq
!
       do i=1,3
          arp(1,i)=0
          arp(i,1)=0
       enddo
       arp(2,2)=-qp*snq
       arp(2,3)=-qp*csq
       arp(3,2)=qp*csq
       arp(3,3)=-qp*snq
!
       do i=1,3
          do j=1,3
             w=0
             wp=0
             do k=1,3
                wp=wp+amp(i,k)*ar(k,j)+am(i,k)*arp(k,j)
                w=w+am(i,k)*ar(k,j)
             enddo
          dp(i,j)=wp
          d(i,j)=w
          enddo
       enddo
!
       do i=1,3
       do j=1,3
          w=0
          wp=0
          do k=1,3
             wp=wp+g(i,k)*dp(k,j)
             w=w+g(i,k)*d(k,j)
          enddo
          dc(i,j)=wp
          c(i,j)=w
       enddo
       enddo
!
       return
       end
!
!
!
       subroutine REF50 (t,c,dc)
!      *************************************************************
!      * Rotation of the reference frame of the theories onto      *
!      *          the FK4 reference frame                          *
!      * Input  : t = ephemeris time in days reckoned from J2000.0 *
!      * Output : c(3,3)  = rotation matrix                        *
!      *          dc(3,3) = derivative of the rotation matrix      *
!      *************************************************************
!
       implicit double precision(a-h,o-z)
!
       dimension ar(3,3),am(3,3),g(3,3),c(3,3),d(3,3)
       dimension arp(3,3),amp(3,3),dc(3,3),dp(3,3)
!
       data g/ 0.999925674124d0,-0.011181963465d0,-0.004859004081d0,      edyfk4
     1         0.012192051720d0, 0.917413967951d0, 0.397747363640d0,      edyfk4
     2         0.000010121726d0,-0.397777041948d0, 0.917482111431d0/      edyfk4
       tm=t/365250.d0
       rad=1.d0/206264.8062470964d0
       deg=3600*rad
!
       ah=178409.13618d0*rad+tm*(-0.5149158068948755d-1
     +     +tm*(-0.1117775392103901d-2-0.3427183852553758d-4*tm))
       gam=0.1614120767052974d-1+tm*(-0.710928404247926d-3
     +     +tm*(-0.1968131454406586d-4-0.2505007528551377d-6*tm))
           tet=(35.496817571d0+2.507593d-6*t)*deg
!
       ahp=(-0.5149158068948755d-1
     +     +tm*(-0.1117775392103901d-2*2
     +     -0.3427183852553758d-4*3*tm))/365250.d0
       gamp=(-0.710928404247926d-3
     +     +tm*(-0.1968131454406586d-4*2
     +     -0.2505007528551377d-6*3*tm))/365250.d0
       tetp=2.507593d-6*deg
       thp=ahp+tetp
       ggp=4*gam*gamp
!
       csh=cos(ah)
       snh=sin(ah)
       cst=cos(tet)
       snt=sin(tet)
       csth=csh*cst-snh*snt
       snth=snt*csh+snh*cst
       gm2=gam*gam
       rac=sqrt(1-gm2)
       gm2=2*gm2
!
       am(1,1)=csth+gm2*snh*snt
       am(1,2)=-snth+gm2*snh*cst
       am(2,1)=snth-gm2*csh*snt
       am(2,2)=csth-gm2*csh*cst
       coef=2*gam*rac
       am(1,3)=coef*snh
       am(2,3)=-coef*csh
       am(3,1)=coef*snt
       am(3,2)=coef*cst
       am(3,3)=1-gm2
!
       amp(1,1)=-thp*snth+ggp*snh*snt+gm2*(ahp*csh*snt+tetp*snh*cst)
       amp(1,2)=-thp*csth+ggp*snh*cst+gm2*(ahp*csh*cst-tetp*snh*snt)
       amp(2,1)=thp*csth-ggp*csh*snt+gm2*(ahp*snh*snt-tetp*csh*cst)
       amp(2,2)=-thp*snth-ggp*csh*cst+gm2*(ahp*snh*cst+tetp*csh*snt)
       coefp=2*gamp*(1-gm2)/rac
       amp(1,3)=coef*ahp*csh+coefp*snh
       amp(2,3)=coef*ahp*snh-coefp*csh
       amp(3,1)=coef*tetp*cst+coefp*snt
       amp(3,2)=-coef*tetp*snt+coefp*cst
       amp(3,3)=-4*gam*gamp
!
       q=(25.192028020d0+3.269878d-7*t)*deg
       qp=3.269878d-7*deg
       csq=cos(q)
       snq=sin(q)
!
       ar(1,1)=1
       do i=2,3
          ar(1,i)=0
          ar(i,1)=0
       enddo
       ar(2,2)=csq
       ar(2,3)=-snq
       ar(3,2)=snq
       ar(3,3)=csq
!
       do i=1,3
          arp(1,i)=0
          arp(i,1)=0
       enddo
       arp(2,2)=-qp*snq
       arp(2,3)=-qp*csq
       arp(3,2)=qp*csq
       arp(3,3)=-qp*snq
!
       do i=1,3
          do j=1,3
             w=0
             wp=0
             do k=1,3
                wp=wp+amp(i,k)*ar(k,j)+am(i,k)*arp(k,j)
                w=w+am(i,k)*ar(k,j)
             enddo
             dp(i,j)=wp
             d(i,j)=w
          enddo
       enddo
!
       do i=1,3
       do j=1,3
          w=0
          wp=0
          do k=1,3
             wp=wp+g(i,k)*dp(k,j)
             w=w+g(i,k)*d(k,j)
          enddo
          dc(i,j)=wp
          c(i,j)=w
       enddo
       enddo
!
       return
       end
!
!
!
       subroutine LEC
!      *********************************************************
!      * Transformation of the series from ESAPHO.             *
!      * Introduction of the new constants in the coefficients *
!      * and in the mean motions                               *
!      *********************************************************
!
       implicit double precision(a-h,o-z)
!
       parameter(id=31,idv=36)
!
       dimension f(6),a0(6),ai(6),pf(6),al(3)
       dimension nb(3),nbv(3),iar(6),ic1(4),ic2(4)
       dimension arg(id,3),freq(id,3),cs(id,3),cc(id,3),
     +           freq2(id,3)
       dimension argv(idv,3),freqv(idv,3),cvs(idv,3),cvc(idv,3),
     +           frev2(idv,3)
       dimension asup(4),fsup(4),rx1s(4),rx2s(4)
!
       character x1(18)*57,x2(18)*57,x3(10)*57,y1(18)*51,
     1 y2(18)*51,y3(10)*51,v1(18)*61,v2(18)*61,v3(12)*61,
     2 w1(18)*56,w2(18)*56,w3(12)*56,
     3 x1p(9)*57,x2p(9)*57,y1p(9)*51,y2p(9)*51,
     4 v1p(14)*61,v2p(14)*61,w1p(14)*56,w2p(14)*56,
     5 x(27,3)*57,v(32,3)*61,y(27,3)*51,w(32,3)*56
!
       equivalence (x(1,1),x1(1)),(y(1,1),y1(1)),(x(19,1),x1p(1)),
     1 (y(19,1),y1p(1)),(x(1,2),x2(1)),(y(1,2),y2(1)),
     2 (x(19,2),x2p(1)),(y(19,2),y2p(1)),
     3 (x(1,3),x3(1)),(y(1,3),y3(1)),(v(1,1),v1(1)),
     4 (w(1,1),w1(1)),(v(19,1),v1p(1)),(w(19,1),w1p(1)),
     5 (v(1,2),v2(1)),(w(1,2),w2(1)),(v(19,2),v2p(1)),
     6 (w(19,2),w2p(1)),(v(1,3),v3(1)),(w(1,3),w3(1))
!
       common/ep5/arg,freq,cs,cc,freq2,argv,freqv,cvs,cvc,frev2
       common/ep4/nb,nbv
       common/ep1/dnu,dgam,de,al
       common/ep3/psi0,pipet,alm,dp
       common/ep2/accep
!
!      ****************************
!      * Coefficients from ESAPHO *
!      ****************************
       data x1/
     1'  0  1  1  0  0  1 9372991.9756-6247057  -181222  -140805',
     2'  0  1  1  0 -1  1 -210991.0229  140430     4098-14066059',
     3'  0  1  1  0  1  1   70361.4467  -46804    -1370  4689174',
     4'  0  1 -1  0  1  1    -970.2930   -9509      752   -64574',
     5'  0  1  1 -2  0  1     873.8556    -582   180963      -13',
     6'  0  1  1 -1  0  1       0.0000       0        0        0',
     7'  0  1  1  0  2  1     791.9808    -526      -15   105574',
     8'  0  1  1  0  0  0     448.5114    -754       -9       -8',
     9'  0  1  1  0  0  2    -448.4011     754       10        6',
     1'  0  2  2 -1  0  3   -1155.9707   -7995   -32964      -90',
     2'  0  1  3  0 -1  1     324.0074    3139     -250    21398',
     3'  0  0  0  1  0 -1    1144.9013    7898    31815       87',
     4'  0  1 -1  0  0  1     289.6238    -451       -1      319',
     5'  0  3  1  0  0  3    -288.9041     480       30        4',
     6'  0  1  1  0 -2  1     265.2220    -175       -5    35366',
     7'  0  1  1  1  0  1      -0.0058       0        0        0',
     8'  0  2  2 -1  0  2    -144.5293     591   -15329       10',
     9'  0  0  0  1  0  0     144.4057    -592    15314       -8'/
       data x1p/
     1'  2 -3 -3  0  0 -3     117.0670     -90       -6       -3',
     2'  2 -1 -1  0  0 -1     -89.5280     397       26        1',
     3'  1  0  0  0  0  0      86.9834     307      -25       13',
     4'  0  1  3  0 -2  1    -135.9361   -1940       62   -10809',
     5'  0  1 -1  0  1  2     -79.1722     -99       16    -5280',
     6'  0  1 -1  0  2  1     126.1976    1845      -55     9510',
     7'  0  3  1  0  0  4     -63.2560     103        0        0',
     8'  0  1 -1  0  0  2      62.8875    -101        6       26',
     9'  1 -2 -2  0  0 -2     -51.7171    -183       15        2'/
       data x2/
     1'  0  1  1  0  0  1 9372992.3416-6247058  -181236  -140791',
     2'  0  1  1  0 -1  1 -211031.5150  140592     4090-14068768',
     3'  0  1  1  0  1  1   70361.4463  -46804    -1370  4689174',
     4'  0  1 -1  0  1  1    -980.1755   -9494      752   -65240',
     5'  0  1  1 -2  0  1     874.2215    -583   181040      -13',
     6'  0  1  1 -1  0  1       0.0000       0        0        0',
     7'  0  1  1  0  2  1     791.9808    -526      -15   105574',
     8'  0  1  1  0  0  0     448.5885    -755       -9       -4',
     9'  0  1  1  0  0  2    -448.1873     755        5        6',
     1'  0  2  2 -1  0  3   -1155.9709   -7995   -32964      -90',
     2'  0  1  3  0 -1  1     324.0074    3139     -250    21398',
     3'  0  0  0  1  0 -1    1146.7820    7893    32010       87',
     4'  0  3  1  0  0  3    -288.8736     480       31        4',
     5'  0  1 -1  0  0  1    -288.7630     510       59      328',
     6'  0  1  1  1  0  1      -0.0058       0        0        0',
     7'  0  1  1  0 -2  1     264.0031    -174       -5    35204',
     8'  0  0  0  1  0  0     173.0304    -710    18389      -14',
     9'  0  2  2 -1  0  2    -144.5289     591   -15329       10'/
       data x2p/
     1'  2 -3 -3  0  0 -3    -117.0670      90        6        3',
     2'  2 -1 -1  0  0 -1     -89.5279     397       26        1',
     3'  1  0  0  0  0  0      86.9835     307      -25       13',
     4'  0  1  3  0 -2  1    -135.9356   -1940       62   -10809',
     5'  0  1 -1  0  1  2     -81.3238     -96       16    -5426',
     6'  0  1 -1  0  2  1     126.2383    1845      -55     9516',
     7'  0  1 -1  0  0  2     -63.8267     106        8       26',
     8'  0  3  1  0  0  4     -63.2563     103        0        0',
     9'  1 -2 -2  0  0 -2      51.7171     183      -15       -2'/
       data x3/
     1'  0  0  0  1  0  0  181017.8207 -120692 18741486    -2723',
     2'  0  0  0  1 -1  0   -4077.2629    2713  -422134  -271818',
     3'  0  1  1  0  0  1   -1481.2817    6135     -651      114',
     4'  0  0  0  1  1  0    1360.2586    -903   140832    90654',
     5'  0  1  1  0  0  2    1054.3326   10180    -1477      293',
     6'  0  1 -1  0  0  1    -457.2263    1074      -94       14',
     7'  0  0  0  0  1  0       0.0074       0        0        0',
     8'  0  1 -1  0  0  2    -110.8858     239      -19        2',
     9'  0  1  1  0  0  0     -97.1704     265      -24        4',
     1'  0  3  1  0  0  3      55.2317       0       -4        0'/
       data v1/
     1'  0  1  1  0  0  1-184667147.923 -61587324  3570444   2774147',
     2'  0  1  1  0 -1  1      1606.495      2670     -278    107003',
     3'  0  1  1  0  1  1  -2771993.617   -927369    53890-184737001',
     4'  0  1  1 -2  0  1     17230.055      5772  3568097      -255',
     5'  0  1  1  0  2  1    -46798.873    -15701      884  -6238465',
     6'  0  1  1  0  0  0     -8832.492      6011      177       157',
     7'  0  1  1  0  0  2      8838.522     -6027     -197      -118',
     8'  0  2  2 -1  0  3     22776.763    163962   649508      1773',
     9'  0  1  3  0 -1  1    -12763.760   -136428     9848   -842940',
     1'  0  0  0  1  0 -1    -22555.148   -161818  -626771     -1714',
     2'  0  1 -1  0  0  1      5700.884     -3171      -19      6279',
     3'  0  3  1  0  0  3      5697.288     -3773     -591       -78',
     4'  0  1  1  0 -2  1      5221.378      1770      -97    696244',
     5'  0  1  1  1  0  1         0.229         0        0         0',
     6'  0  2  2 -1  0  2      2846.423     -8794   301896      -197',
     7'  0  0  0  1  0  0     -2846.188      8820  -301833       157',
     8'  2 -3 -3  0  0 -3      5485.491      2702     -281      -140',
     9'  2 -1 -1  0  0 -1      -667.307      1195      193         7'/
       data v1p/
     1'  1  0  0  0  0  0      -532.706     -1880      153       -79',
     2'  0  1  3  0 -2  1      2677.804     39842    -1221    212926',
     3'  0  1 -1  0  2  1     -2486.738    -37783     1083   -187395',
     4'  0  3  1  0  0  4      1248.008      -785        0         0',
     5'  0  1 -1  0  0  2      1237.287      -748      118       511',
     6'  1 -2 -2  0  0 -2     -1721.139     -8128      499        66',
     7'  0  1  1  0  0 -1      -617.237       405        0         0',
     8'  0  1  1  0  0  3       616.876      -428        0         0',
     9'  0  3  1  0  0  2      -543.548       343        0        39',
     1'  0  1 -1  0  0  0      -540.379       345      -19       177',
     2'  0  1  3  0 -1  0     -1054.707     -2316      196    -70261',
     3'  0  2  0  1  0  2       517.078      -410    53482         0',
     4'  3 -4 -4  0  0 -4      -845.723     -5333       60       302',
     5'  0  1  1  0  3  1      -832.288      -280        0   -166394'/
       data v2/
     1'  0  1  1  0  0  1 184667155.134  61587311 -3570720  -2773871',
     2'  0  1  1  0 -1  1     -1606.803     -2670      278   -107023',
     3'  0  1  1  0  1  1   2771993.601    927369   -53890 184737001',
     4'  0  1  1 -2  0  1    -17237.270     -5759 -3569615       255',
     5'  0  1  1  0  2  1     46798.873     15701     -884   6238465',
     6'  0  1  1  0  0  0      8834.010     -6030     -177       -78',
     7'  0  1  1  0  0  2     -8834.307      6051       98       118',
     8'  0  2  2 -1  0  3    -22776.766   -163962  -649508     -1773',
     9'  0  1  3  0 -1  1     12763.760    136428    -9848    842940',
     1'  0  0  0  1  0 -1     22592.199    161756   630613      1714',
     2'  0  3  1  0  0  3     -5696.686      3774      611        78',
     3'  0  1 -1  0  0  1      5683.941     -4349    -1161     -6456',
     4'  0  1  1  1  0  1        -0.229         0        0         0',
     5'  0  1  1  0 -2  1     -5197.382     -1766       97   -693055',
     6'  0  0  0  1  0  0      3410.371    -10581   362440      -275',
     7'  0  2  2 -1  0  2     -2846.415      8794  -301896       197',
     8'  2 -3 -3  0  0 -3      5485.491      2702     -281      -140',
     9'  2 -1 -1  0  0 -1       667.306     -1195     -193        -7'/
       data v2p/
     1'  1  0  0  0  0  0       532.706      1880     -153        79',
     2'  0  1  3  0 -2  1     -2677.794    -39842     1221   -212926',
     3'  0  1 -1  0  2  1      2487.540     37784    -1083    187513',
     4'  0  1 -1  0  0  2      1255.765      -827     -157      -511',
     5'  0  3  1  0  0  4     -1248.014       785        0         0',
     6'  1 -2 -2  0  0 -2     -1721.139     -8128      499        66',
     7'  0  1  1  0  0 -1       617.168      -405        0         0',
     8'  0  1  1  0  0  3      -617.663       408        0         0',
     9'  0  1 -1  0  0  0      -547.417       358       39      -118',
     1'  0  3  1  0  0  2       543.495      -343        0       -39',
     2'  0  2  0  1  0  2      -538.076       389   -55652         0',
     3'  0  1  3  0 -1  0      1054.707      2316     -196     70261',
     4'  3 -4 -4  0  0 -4      -845.723     -5333       60       302',
     5'  0  1  1  0  3  1       832.288       280        0    166394'/
       data v3/
     1'  0  0  0  1  0  0   3567800.464   1190831369388343    -53586',
     2'  0  1  1  0  0  1    -29184.285     91687   -12826      2246',
     3'  0  0  0  1  1  0     53599.765     18017  5549359   3572140',
     4'  0  1  1  0  0  2     20782.155    221432   -29113      5775',
     5'  0  1 -1  0  0  1      8999.931    -12132     1850      -275',
     6'  0  0  0  0  1  0         0.146         0        0         0',
     7'  0  1 -1  0  0  2      2181.635     -2517      373       -39',
     8'  0  1  1  0  0  0     -1913.567      3304     -472        78',
     9'  0  3  1  0  0  3      1089.188      1088      -78         0',
     1'  2 -2 -2  0  0 -2        13.355        19        0         0',
     2'  0  1 -1  0  0  0      -664.567      1146     -177        19',
     3'  0  0  0  1  2  0       905.431       314    93730    120442'/
       data y1/
     1'       -0.0001     0     0     0     0          -56',
     2'       -0.0002     0     0     0     0            1',
     3'        0.0000     0     0     0     0            0',
     4'       -0.0028     0     0     0     0          -11',
     5'        0.0000     0     0     0     0            0',
     6'     -794.4492     3-76760   -34     0            0',
     7'        0.0000     0     0     0     0            0',
     8'        0.0011     0     0     0     0          -24',
     9'        0.0011     0     0     0     0           23',
     1'        0.1201     0     0     0     0          -78',
     2'       -0.0009     0     0     0     0            3',
     3'        0.1199     0     0     0     0           77',
     4'        0.0001     0     0     0     0          -15',
     5'       -0.0001     0     0     0     0           15',
     6'        0.0000     0     0     0     0            0',
     7'     -264.4599     1-25560    16     0            0',
     8'       -0.0079     0     0     0     0        -6956',
     9'       -0.0104     0     0     0     0         6953'/
       data y1p/
     1'       -0.0475     0     0     0     0            0',
     2'        6.3708     0     0     0     0            0',
     3'       -8.6457   -22     1    -1     0            0',
     4'        0.0103     0     0     0     0           -1',
     5'        0.0000     0     0     0     0           -1',
     6'        0.0103     0     0     0     0            1',
     7'        0.0000     0     0     0     0            2',
     8'        0.0000     0     0     0     0           -2',
     9'        4.9764    13    -1     0     0            0'/
       data y2/
     1'        0.0001     0     0     0     0          -73',
     2'       -0.0001     0     0     0     0            2',
     3'        0.0000     0     0     0     0            0',
     4'        0.0029     0     0     0     0          -11',
     5'        0.0000     0     0     0     0            0',
     6'      794.4491    -3 76760    34     0            0',
     7'        0.0000     0     0     0     0            0',
     8'       -0.0011     0     0     0     0          -25',
     9'       -0.0011     0     0     0     0           35',
     1'       -0.1201     0     0     0     0          -78',
     2'        0.0009     0     0     0     0            3',
     3'       -0.1199     0     0     0     0           77',
     4'        0.0001     0     0     0     0           16',
     5'        0.0000     0     0     0     0           10',
     6'      264.4599    -1 25560   -16     0            0',
     7'        0.0000     0     0     0     0            0',
     8'        0.0079     0     0     0     0         8947',
     9'        0.0079     0     0     0     0        -6956'/
       data y2p/
     1'       -0.0475     0     0     0     0            0',
     2'       -6.3708     0     0     0     0            0',
     3'        8.6457    22    -1     1     0            0',
     4'       -0.0103     0     0     0     0           -1',
     5'        0.0000     0     0     0     0           -1',
     6'       -0.0103     0     0     0     0            1',
     7'        0.0000     0     0     0     0            1',
     8'        0.0000     0     0     0     0            2',
     9'        4.9764    13    -1     0     0            0'/
       data y3/
     1'        0.0000     0     0     0     0           -3',
     2'        0.0000     0     0     0     0            0',
     3'        0.1294     0     0     0     0      -103296',
     4'        0.0000     0     0     0     0            0',
     5'        0.0184     0     0     0     0          106',
     6'        0.0000     0     0     0     0            5',
     7'      411.3091     0   -40 25602     0            0',
     8'        0.0000     0     0     0     0            1',
     9'        0.0000     0     0     0     0           -2',
     1'        0.0000     0     0     0     0            2'/
       data w1/
     1'         -0.002     0       0      0     0          1103',
     2'          0.000     0       0      0     0           -37',
     3'          0.000     0       0      0     0           -12',
     4'          0.000     0       0      0     0             0',
     5'          0.000     0       0      0     0             0',
     6'          0.022     0       0      0     0           472',
     7'          0.022     0       0      0     0          -453',
     8'          2.366     0       0      0     0          1536',
     9'         -0.035     0       0      0     0          -118',
     1'          2.362     0       0      0     0         -1516',
     2'         -0.002     0       0      0     0          -295',
     3'         -0.002     0       0      0     0          -295',
     4'          0.000     0       0      0     0             0',
     5'     -10422.818-10386-1007363    630     0             0',
     6'         -0.156     0       0      0     0        136994',
     7'         -0.205     0       0      0     0       -137041',
     8'          2.226     2       0      0     0             0',
     9'        -47.485  -125       0      0     0             0'/
       data w1p/
     1'        -52.948  -134       6     -6     0             0',
     2'          0.203     0       0      0     0            19',
     3'          0.203     0       0      0     0           -19',
     4'          0.000     0       0      0     0           -39',
     5'          0.000     0       0      0     0           -39',
     6'       -165.614  -628      33      0     0             0',
     7'          0.000     0       0      0     0             0',
     8'          0.000     0       0      0     0             0',
     9'          0.000     0       0      0     0            59',
     1'          0.000     0       0      0     0            59',
     2'          0.000     0       0      0     0             0',
     3'          0.000     0       0      0     0             0',
     4'        135.835   841       0      0     0             0',
     5'          0.000     0       0      0     0             0'/
       data w2/
     1'         -0.002     0       0      0     0         -1438',
     2'          0.000     0       0      0     0            37',
     3'          0.000     0       0      0     0            12',
     4'          0.000     0       0      0     0             0',
     5'          0.000     0       0      0     0             0',
     6'          0.022     0       0      0     0          -492',
     7'          0.022     0       0      0     0           689',
     8'          2.366     0       0      0     0         -1536',
     9'         -0.035     0       0      0     0           118',
     1'          2.362     0       0      0     0          1516',
     2'         -0.002     0       0      0     0           315',
     3'          0.000     0       0      0     0          -196',
     4'     -10422.818-10386-1007363    630     0             0',
     5'          0.000     0       0      0     0             0',
     6'         -0.156     0       0      0     0        176342',
     7'         -0.156     0       0      0     0       -136994',
     8'         -2.226    -2       0      0     0             0',
     9'        -47.485  -125       0      0     0             0'/
       data w2p/
     1'        -52.948  -134       6     -6     0             0',
     2'          0.203     0       0      0     0           -19',
     3'          0.203     0       0      0     0            19',
     4'          0.000     0       0      0     0           -19',
     5'          0.000     0       0      0     0            39',
     6'        165.614   628     -33      0     0             0',
     7'          0.000     0       0      0     0             0',
     8'          0.000     0       0      0     0             0',
     9'          0.000     0       0      0     0            39',
     1'          0.000     0       0      0     0           -59',
     2'          0.000     0       0      0     0             0',
     3'          0.000     0       0      0     0             0',
     4'       -135.835  -841       0      0     0             0',
     5'          0.000     0       0      0     0             0'/
       data w3/
     1'          0.000     0       0      0     0           -26',
     2'         -2.549    -2       0      0     0      -2035142',
     3'          0.000     0       0      0     0             0',
     4'         -0.363     0       0      0     0          2089',
     5'          0.000     0       0      0     0           -98',
     6'      -8100.500 -8096     787-504217     0             0',
     7'          0.000     0       0      0     0           -19',
     8'          0.000     0       0      0     0           -39',
     9'          0.000     0       0      0     0            39',
     1'      -1306.279 -1135     271   -108     0             0',
     2'          0.000     0       0      0     0             0',
     3'          0.000     0       0      0     0             0'/
!
!      ***************************************
!      * Perturbations by Deimos and planets *
!      ***************************************
       data asup/183.1130d0,199.2812d0,255.194d0,271.3608d0/
       data fsup/1128.826758d0,-1128.862761d0,1128.849665d0,
     +          -1128.839842d0/
       data rx1s/51.71d0,-51.71d0,63.305d0,-63.208d0/
       data rx2s/51.71d0,51.71d0,63.305d0,63.209d0/
!
!      ************************
!      * Arguments in J2000.0 *
!      ************************
       ai(1)=psi0
       ai(2)=pipet
       ai(3)=al(1)-pipet-alm
       ai(4)=al(1)-al(2)
       ai(5)=al(1)-al(3)
       ai(6)=alm
!
!      ****************************
!      * Mean motions from ESAPHO *
!      ****************************
       data fipsi/350.8919885d0/
       data fipi/0.1772311d-4/
       data fid/1128.3207210d0/
       data fif/1129.280784d0/
       data fil/1128.409439d0/
       data filp/0.5240207d0/
       data fnu/1128.84426d0/
!
       dpn=dp*1.d5/fnu
       dnun=dnu/fnu
       pf(1)=fipsi
       pf(2)=fipi
       pf(3)=fid
       pf(4)=fif
       pf(5)=fil
       pf(6)=filp
!
!      *************************
!      * Conversion to radians *
!      *************************
       deg=3600.d0/206264.8062470964d0
       do k=1,6
          f(k)=pf(k)*deg
          a0(k)=ai(k)*deg
       enddo
!
!      *********************************************************
!      * Transformation of the series from ESAPHO for position *
!      *********************************************************
       do i=1,3
          jmax=nb(i)
          do j=1,jmax
             read (x(j,i),1001) iar,r1,(ic1(k),k=1,3)
             read (y(j,i),1002) r2,ic2,ic1(4)
             aw=0
             fw=0
             do k=1,6
                aw=aw+iar(k)*a0(k)
                fw=fw+iar(k)*f(k)
             enddo
             arg(j,i)=aw
             freq(j,i)=fw
             freq2(j,i)=iar(3)+iar(4)+iar(5)
             r1=r1+ic1(1)*dnun+ic1(2)*dgam+ic1(3)*de+ic1(4)*dpn
             r2=r2+ic2(1)*dnun+ic2(2)*dgam+ic2(3)*de+ic2(4)*dpn
             if (i.eq.1) then
                cs(j,i)=r2*1.d-3
                cc(j,i)=r1*1.d-3
             else
                cs(j,i)=r1*1.d-3
                cc(j,i)=r2*1.d-3
             endif
          enddo
          if (i.ne.3) then
             do j=1,4
                jp=jmax+j
                arg(jp,i)=asup(j)*deg
                freq(jp,i)=fsup(j)*deg
                freq2(jp,i)=0
                if (i.eq.1) then
                   cs(jp,i)=0
                   cc(jp,i)=rx1s(j)*1.d-3
                else
                   cs(jp,i)=rx2s(j)*1.d-3
                   cc(jp,i)=0
                endif
             enddo
          endif
       enddo
!
1001   format (6i3,f13.4,i8,2i9)
1002   format (f14.4,4i6,i13)
!
!      *********************************************************
!      * Transformation of the series from ESAPHO for velocity *
!      *********************************************************
       do i=1,3
          jmax=nbv(i)
          do j=1,jmax
             read (v(j,i),2001) iar,r1,(ic1(k),k=1,3)
             read (w(j,i),2002) r2,ic2,ic1(4)
             aw=0
             fw=0
             do k=1,6
                aw=aw+iar(k)*a0(k)
                fw=fw+iar(k)*f(k)
             enddo
             argv(j,i)=aw
             freqv(j,i)=fw
             frev2(j,i)=iar(3)+iar(4)+iar(5)
             r1=r1+ic1(1)*dnun+ic1(2)*dgam+ic1(3)*de+ic1(4)*dpn
             r2=r2+ic2(1)*dnun+ic2(2)*dgam+ic2(3)*de+ic2(4)*dpn
             if (i.ne.1) then
                cvs(j,i)=r2*1.d-3
                cvc(j,i)=r1*1.d-3
             else
                cvs(j,i)=r1*1.d-3
                cvc(j,i)=r2*1.d-3
             endif
          enddo
          if (i.ne.3) then
             do j=1,4
                jp=jmax+j
                argv(jp,i)=asup(j)*deg
                freqv(jp,i)=fsup(j)*deg
                frev2(jp,i)=0
                if (i.eq.1) then
                   cvs(jp,i)=-rx1s(j)*1.d-3*argv(jp,i)
                   cvc(j,i)=0
                else
                   cvs(jp,i)=0
                   cvc(jp,i)=rx2s(j)*1.d-3*argv(jp,i)
                endif
             enddo
          endif
       enddo
!
2001   format (6i3,f14.3,i10,i9,i10)
2002   format (f15.3,i6,i8,i7,i6,i14)
!
       return
       end
!
!
!
       subroutine LECD
!      *********************************************************
!      * Transformation of the series from ESADE.              *
!      * Introduction of the new constants in the coefficients *
!      * and in the mean motions                               *
!      *********************************************************
!
       implicit double precision(a-h,o-z)
!
       parameter(id=38,idv=27)
!
       dimension f(6),a0(6),ai(6),pf(6),al(3)
       dimension nb(3),nbv(3),iar(6),ic1(3)
       dimension arg(id,3),freq(id,3),cs(id,3),cc(id,3),
     +           freq2(id,3)
       dimension argv(idv,3),freqv(idv,3),cvs(idv,3),cvc(idv,3),
     +           frev2(idv,3)
!
       character x1(18)*59,x2(19)*59,x3(18)*59,y1(18)*10,
     1 y2(19)*10,y3(18)*10,v1(18)*63,v2(18)*63,v3(16)*63,
     2 w1(18)*11,w2(18)*11,w3(16)*11,
     3 x1p(19)*59,x2p(19)*59,x3p(7)*59,y1p(19)*10,y2p(19)*10,
     4 y3p(7)*10,v1p(9)*63,v2p(9)*63,w1p(9)*11,w2p(9)*11,
     5 x(38,3)*59,v(27,3)*63,y(38,3)*10,w(27,3)*11
!
       equivalence (x(1,1),x1(1)),(y(1,1),y1(1)),(x(19,1),x1p(1)),
     1 (y(19,1),y1p(1)),(x(1,2),x2(1)),(y(1,2),y2(1)),
     2 (x(20,2),x2p(1)),(y(20,2),y2p(1)),(x(19,3),x3p(1)),
     3 (x(1,3),x3(1)),(y(1,3),y3(1)),(y(19,3),y3p(1)),(v(1,1),v1(1)),
     4 (w(1,1),w1(1)),(v(19,1),v1p(1)),(w(19,1),w1p(1)),
     5 (v(1,2),v2(1)),(w(1,2),w2(1)),(v(19,2),v2p(1)),
     6 (w(19,2),w2p(1)),(v(1,3),v3(1)),(w(1,3),w3(1))
!
       common/ed5/arg,freq,cs,cc,freq2,argv,freqv,cvs,cvc,frev2
       common/ed4/nb,nbv
       common/ed1/dnu,dgam,de,al
       common/ep3/psi0,pipet,alm,dp
       common/ed2/accep
!
!      ***************************
!      * Coefficients from ESADE *
!      ***************************
       data x1/
     1'  0  1  1  0  0  1 23451762.1311-15634508  -727543    -9779',
     2'  0  2  2 -1  0  2   -55151.4362    36767        0        0',
     3'  0  0  0  1  0  0    55133.9035   -36755        0        0',
     4'  0  1  1  0 -1  1   -14544.5209     9696      455-35177119',
     5'  0  1  1 -2  0  1     5602.8085    -3735   727543       -2',
     6'  0  1  1  0  1  1     4890.3869    -3260     -151 11725701',
     7'  0  1  1  0  0  0     4551.1609    -3034        0        0',
     8'  0  1  1  0  0  2    -4545.4296     3030        0        0',
     9'  2 -3 -3  0  0 -3    -3251.3962     2167        0        0',
     1'  0  3  1  0  0  3    -2659.0343     1772        0        0',
     2'  0  1 -1  0  0  1     2592.0639    -1728        0        0',
     3'  2 -1 -1  0  0 -1     1868.9622    -1245        0        0',
     4'  0  1  1 -1  0  1        0.0000        0        0        0',
     5'  0  3  1  0  0  4     -581.0963      387        0        0',
     6'  0  1 -1  0  0  2      558.8118     -372        0        0',
     7'  0  2  2  0  0  2        0.0000        0        0        0',
     8'  0  2  0  1  0  2     -390.0656      260        0        0',
     9'  0  1  1  1  0  1        0.0000        0        0        0'/
       data x1p/
     1'  3 -4 -4  0  0 -4      280.7530     -187        0        0',
     2'  0  1  1  0  0 -1      318.5942     -212        0        0',
     3'  0  1  1  0  0  3     -316.7712      211        0        0',
     4'  0  0  2 -1  0  0      288.9456     -192        0        0',
     5'  0  3  1  0  0  2      255.1685     -170        0        0',
     6'  0  1 -1  0  0  0     -252.9696      168        0        0',
     7'  1 -2 -2  0  0 -2      157.2017     -104        0        0',
     8'  0  3  3 -2  0  3      148.1044      -98        0        0',
     9'  3 -2 -2  0  0 -2     -126.2662       84        0        0',
     1'  1  0  0  0  0  0     -119.1380       79        0        0',
     2'  0  0  0  1  0  1      125.3480      -83        0        0',
     3'  0  0  0  1  0 -1     -118.4993       78        0        0',
     4'  0  3  1  0  0  5      -98.7740       65        0        0',
     5'  0  2  2 -1  0  1      -94.0167       62        0        0',
     6'  0  1 -1  0  0  3       93.6378      -62        0        0',
     7'  0  2  2 -1  0  3       86.4433      -57        0        0',
     8'  0  2  0 -1  0  2       85.1187      -56        0        0',
     9'  0  2  0  1  0  3      -84.9226       56        0        0',
     1'  0  0  2 -1  0 -1       62.9106      -41        0        0'/
       data x2/
     1'  0  1  1  0  0  1 23448856.2674-15632570  -727543    -9779',
     2'  0  0  0  1  0  0    66507.3861   -44338        0        0',
     3'  0  2  2 -1  0  2   -55124.5490    36749        0        0',
     4'  0  1  1  0 -1  1   -14794.1622     9862      455-35177119',
     5'  0  1  1 -2  0  1     5652.0343    -3768   727543       -2',
     6'  0  1  1  0  1  1     4889.7715    -3259     -151 11725701',
     7'  0  1  1  0  0  0     4526.5150    -3017        0        0',
     8'  0  1  1  0  0  2    -4514.4268     3009        0        0',
     9'  2 -3 -3  0  0 -3     3250.9885    -2167        0        0',
     1'  0  1 -1  0  0  1    -2843.1994     1895        0        0',
     2'  0  3  1  0  0  3    -2653.7375     1769        0        0',
     3'  2 -1 -1  0  0 -1     1868.6828    -1245        0        0',
     4'  0  0  0  0  0  0        0.0000        0        0        0',
     5'  0  1  1 -1  0  1        0.0000        0        0        0',
     6'  0  1 -1  0  0  2     -632.9468      421        0        0',
     7'  0  3  1  0  0  4     -579.9308      386        0        0',
     8'  0  2  0  1  0  2     -399.2736      266        0        0',
     9'  0  2  2  0  0  2        0.0000        0        0        0',
     1'  0  1  1  1  0  1        0.0000        0        0        0'/
       data x2p/
     2'  3 -4 -4  0  0 -4     -280.7182      187        0        0',
     3'  0  1  1  0  0 -1      316.9349     -211        0        0',
     4'  0  1  1  0  0  3     -314.5569      209        0        0',
     5'  0  0  2 -1  0  0      294.7831     -196        0        0',
     6'  0  1 -1  0  0  0      269.2981     -179        0        0',
     7'  0  3  1  0  0  2      254.6917     -169        0        0',
     8'  1 -2 -2  0  0 -2     -157.1732      104        0        0',
     9'  0  3  3 -2  0  3      148.0042      -98        0        0',
     1'  3 -2 -2  0  0 -2     -126.2468       84        0        0',
     2'  1  0  0  0  0  0     -119.1139       79        0        0',
     3'  0  1 -1  0  0  3     -109.5100       73        0        0',
     4'  0  2  0 -1  0  2      106.0245      -70        0        0',
     5'  0  3  1  0  0  5      -98.5724       65        0        0',
     6'  0  2  2 -1  0  1      -93.6819       62        0        0',
     7'  0  2  0  1  0  3      -86.9127       57        0        0',
     8'  0  2  2 -1  0  3       86.0623      -57        0        0',
     9'  0  0  0  1  0  1       70.1733      -46        0        0',
     1'  0  0  0  1  0 -1      -66.2919       44        0        0',
     2'  0  0  2 -1  0 -1       64.1928      -42        0        0'/
       data x3/
     1'  0  0  0  1  0  0   726494.5032  -484329 46897178     -303',
     2'  0  1  1  0  0  1  -367660.3813   245106        0        0',
     3'  0  1 -1  0  0  1    -6081.1262     4054        0        0',
     4'  0  2  2 -1  0  2     2149.8425    -1433        0        0',
     5'  0  1  1  0  0  2     1844.8540    -1229        0        0',
     6'  0  1  1 -2  0  1    -1799.3963     1199        0        0',
     7'  0  1  1  0  0  0    -1729.1650     1152        0        0',
     8'  0  1 -1  0  0  2    -1339.1617      892        0        0',
     9'  0  1 -1  0  0  0      574.0342     -382        0        0',
     1'  0  0  0  1 -1  0     -454.8726      303   -29334 -1091184',
     2'  0  0  2 -1  0  0      417.5738     -278        0        0',
     3'  0  3  1  0  0  3      333.6614     -222        0        0',
     4'  0  1  1  0 -1  1      230.5734     -153        0        0',
     5'  0  1 -1  0  0  3     -228.7458      152        0        0',
     6'  0  0  0  1  1  0      151.3386     -100     9778   363728',
     7'  0  1  1  0  0  3      126.3330      -84        0        0',
     8'  0  1  1  0  0 -1     -123.0024       82        0        0',
     9'  2 -2 -2 -1  0 -2      100.4703      -66        0        0'/
       data x3p/
     1'  0  0  2 -1  0 -1       92.7574      -61        0        0',
     2'  0  1  1  0  1  1      -77.0433       51        0        0',
     3'  0  3  1  0  0  4       72.3397      -48        0        0',
     4'  2 -2 -2  1  0 -2       63.1447      -42        0        0',
     5'  0  0  0  0  0  0        0.0000        0        0        0',
     6'  0  1  1 -1  0  1        0.0000        0        0        0',
     7'  2 -3 -3  0  0 -3      -51.4568       34        0        0'/
       data v1/
     1'  0  1  1  0  0  1 -116719753.045 -38906584   3620991     48670',
     2'  0  2  2 -1  0  2     274472.052     91511         0         0',
     3'  0  0  0  1  0  0    -274419.644    -91460         0         0',
     4'  0  1  1 -2  0  1      27888.799      9293   3621451        -9',
     5'  0  1  1  0  1  1     -48677.506    -16229      1503-116714258',
     6'  0  1  1  0  0  0     -22609.568     -7578         0         0',
     7'  0  1  1  0  0  2      22664.240      7514         0         0',
     8'  2 -3 -3  0  0 -3      -8722.200    -42733         0         0',
     9'  0  3  1  0  0  3      13282.692      4382         0         0',
     1'  0  1 -1  0  0  1      12853.324      4332         0         0',
     2'  2 -1 -1  0  0 -1     -13590.022     18354         0         0',
     3'  0  3  1  0  0  4       2908.069       955         0         0',
     4'  0  1 -1  0  0  2       2765.881       939         0         0',
     5'  0  2  2  0  0  2          0.000         0         0         0',
     6'  0  2  0  1  0  2       1948.621       642         0         0',
     7'  0  1  1  1  0  1          0.000         0         0         0',
     8'  0  1  1  0  0 -1      -1579.820      -534         0         0',
     9'  0  1  1  0  0  3       1582.369       522         0         0'/
       data v1p/
     1'  0  0  2 -1  0  0      -1432.710      -486         0         0',
     2'  0  3  1  0  0  2      -1272.311      -422         0         0',
     3'  0  1 -1  0  0  0      -1256.720      -424         0         0',
     4'  1 -2 -2  0  0 -2        602.052      1166         0         0',
     5'  0  3  3 -2  0  3       -737.024      -249         0         0',
     6'  3 -2 -2  0  0 -2       1062.989     -1964         0         0',
     7'  1  0  0  0  0  0        729.627      -483         0         0',
     8'  0  0  0  1  0  1       -625.045      -209         0         0',
     9'  0  0  0  1  0 -1        588.726       202         0         0'/
       data v2/
     1'  0  1  1  0  0  1  116705290.520  38901767  -3620991    -48670',
     2'  0  0  0  1  0  0     331029.222    110323         0         0',
     3'  0  2  2 -1  0  2    -274338.243    -91466         0         0',
     4'  0  1  1 -2  0  1     -28133.827     -9374  -3621451         9',
     5'  0  1  1  0  1  1      48671.381     16233     -1503 116714258',
     6'  0  1  1  0  0  0      22487.130      7540         0         0',
     7'  0  1  1  0  0  2     -22509.655     -7465         0         0',
     8'  2 -3 -3  0  0 -3      -8721.107    -42727         0         0',
     9'  0  1 -1  0  0  1      14098.635      4753         0         0',
     1'  0  3  1  0  0  3     -13256.232     -4370         0         0',
     2'  2 -1 -1  0  0 -1      13587.990    -18353         0         0',
     3'  0  1 -1  0  0  2       3132.818      1066         0         0',
     4'  0  3  1  0  0  4      -2902.236      -954         0         0',
     5'  0  2  0  1  0  2      -1994.620      -658         0         0',
     6'  0  2  2  0  0  2          0.000         0         0         0',
     7'  0  1  1  1  0  1          0.000         0         0         0',
     8'  0  1  1  0  0 -1       1571.592       531         0         0',
     9'  0  1  1  0  0  3      -1571.308      -521         0         0'/
       data v2p/
     1'  0  0  2 -1  0  0       1461.654       495         0         0',
     2'  0  1 -1  0  0  0      -1337.837      -451         0         0',
     3'  0  3  1  0  0  2       1269.934       424         0         0',
     4'  1 -2 -2  0  0 -2        601.943      1166         0         0',
     5'  0  3  3 -2  0  3        736.525       248         0         0',
     6'  3 -2 -2  0  0 -2      -1062.825      1963         0         0',
     7'  1  0  0  0  0  0       -729.480       483         0         0',
     8'  0  1 -1  0  0  3        541.026       184         0         0',
     9'  0  2  0 -1  0  2       -525.780      -180         0         0'/
       data v3/
     1'  0  0  0  1  0  0    3616003.041   1205108 233422741     -1508',
     2'  0  1  1  0  0  1   -1829850.937   -609954         0         0',
     3'  0  1 -1  0  0  1      30154.613     10163         0         0',
     4'  0  2  2 -1  0  2      10699.117      3568         0         0',
     5'  0  1  1  0  0  2       9198.737      3053         0         0',
     6'  0  1  1 -2  0  1       8956.758      2987         0         0',
     7'  0  1  1  0  0  0      -8590.264     -2883         0         0',
     8'  0  1 -1  0  0  2       6628.283      2250         0         0',
     9'  0  1 -1  0  0  0      -2851.726      -959         0         0',
     1'  0  0  2 -1  0  0       2070.500       699         0         0',
     2'  0  3  1  0  0  3       1666.741       551         0         0',
     3'  0  1 -1  0  0  3       1130.103       387         0         0',
     4'  0  0  0  1  1  0       1506.429       511     97330   3620558',
     5'  0  1  1  0  0  3        631.072       209         0         0',
     6'  0  1  1  0  0 -1       -609.935      -205         0         0',
     7'  0  1  1  0  1  1       -766.867      -259         0         0'/
       data y1/
     1'    0.0000',
     2'    0.0000',
     3'    0.0000',
     4'    0.0000',
     5'    0.0000',
     6'    0.0000',
     7'    0.0000',
     8'    0.0000',
     9'   -0.0020',
     1'    0.0000',
     2'    0.0000',
     3'    0.0007',
     4'-1157.0034',
     5'    0.0000',
     6'    0.0000',
     7'  395.4635',
     8'    0.0000',
     9' -383.9143'/
       data y1p/
     1'   45.6488',
     2'    0.0000',
     3'    0.0000',
     4'    0.0000',
     5'    0.0000',
     6'    0.0000',
     7'  -11.6027',
     8'    0.0000',
     9'  -20.5254',
     1'    8.8034',
     2'    0.0000',
     3'    0.0000',
     4'    0.0000',
     5'    0.0000',
     6'    0.0000',
     7'    0.0000',
     8'    0.0000',
     9'    0.0000',
     1'    0.0000'/
       data y2/
     1'    0.0000',
     2'    0.0000',
     3'    0.0000',
     4'    0.0000',
     5'    0.0000',
     6'    0.0000',
     7'    0.0000',
     8'    0.0000',
     9'   -0.0020',
     1'    0.0000',
     2'    0.0000',
     3'   -0.0007',
     4'-1180.2676',
     5' 1156.5679',
     6'    0.0000',
     7'    0.0000',
     8'    0.0000',
     9' -395.4136',
     1'  383.6747'/
       data y2p/
     2'   45.6431',
     3'    0.0000',
     4'    0.0000',
     5'    0.0000',
     6'    0.0000',
     7'    0.0000',
     8'  -11.6006',
     9'    0.0000',
     1'   20.5223',
     2'   -8.8016',
     3'    0.0000',
     4'    0.0000',
     5'    0.0000',
     6'    0.0000',
     7'    0.0000',
     8'    0.0000',
     9'    0.0000',
     1'    0.0000',
     2'    0.0000'/
       data y3/
     1'    0.0000',
     2'    0.0000',
     3'    0.0000',
     4'    0.0000',
     5'    0.0000',
     6'    0.0000',
     7'    0.0000',
     8'    0.0000',
     9'    0.0000',
     1'    0.0000',
     2'    0.0000',
     3'    0.0000',
     4'    0.0000',
     5'    0.0000',
     6'    0.0000',
     7'    0.0000',
     8'    0.0000',
     9'    0.0000'/
       data y3p/
     1'    0.0000',
     2'    0.0000',
     3'    0.0000',
     4'    0.0000',
     5'   57.4788',
     6'  -54.7313',
     7'    0.0000'/
       data w1/
     1'      0.000',
     2'      0.000',
     3'      0.000',
     4'      0.000',
     5'      0.000',
     6'      0.000',
     7'      0.000',
     8'      0.005',
     9'      0.000',
     1'      0.000',
     2'      0.005',
     3'      0.000',
     4'      0.000',
     5'   3936.455',
     6'      0.000',
     7'  -3821.615',
     8'      0.000',
     9'      0.000'/
       data w1p/
     1'      0.000',
     2'      0.000',
     3'      0.000',
     4'     44.436',
     5'      0.000',
     6'   -172.796',
     7'     53.914',
     8'      0.000',
     9'      0.000'/
       data w2/
     1'      0.000',
     2'      0.000',
     3'      0.000',
     4'      0.000',
     5'      0.000',
     6'      0.000',
     7'      0.000',
     8'     -0.005',
     9'      0.000',
     1'      0.000',
     2'      0.005',
     3'      0.000',
     4'      0.000',
     5'      0.000',
     6'   3935.958',
     7'  -3819.230',
     8'      0.000',
     9'      0.000'/
       data w2p/
     1'      0.000',
     2'      0.000',
     3'      0.000',
     4'    -44.428',
     5'      0.000',
     6'   -172.770',
     7'     53.903',
     8'      0.000',
     9'      0.000'/
       data w3/
     1'      0.000',
     2'      0.000',
     3'      0.000',
     4'      0.000',
     5'      0.000',
     6'      0.000',
     7'      0.000',
     8'      0.000',
     9'      0.000',
     1'      0.000',
     2'      0.000',
     3'      0.000',
     4'      0.000',
     5'      0.000',
     6'      0.000',
     7'      0.000'/
!
!      ************************
!      * Arguments in J2000.0 *
!      ************************
       ai(1)=psi0
       ai(2)=pipet
       ai(3)=al(1)-pipet-alm
       ai(4)=al(1)-al(2)
       ai(5)=al(1)-al(3)
       ai(6)=alm
!
!      ***************************
!      * Mean motions from ESADE *
!      ***************************
       data fipsi/350.8919885d0/
       data fipi/0.1772311d-4/
       data fid/284.6378363d0/
       data fif/285.179876d0/
       data fil/285.143868d0/
       data filp/0.5240207d0/
       data fnu/285.161908d0/
!
       dnun=dnu/fnu
       pf(1)=fipsi
       pf(2)=fipi
       pf(3)=fid
       pf(4)=fif
       pf(5)=fil
       pf(6)=filp
!
!      *************************
!      * Conversion to radians *
!      *************************
       deg=3600.d0/206264.8062470964d0
       do k=1,6
          f(k)=pf(k)*deg
          a0(k)=ai(k)*deg
       enddo
!
!      ********************************************************
!      * Transformation of the series from ESADE for position *
!      ********************************************************
       do i=1,3
          jmax=nb(i)
          do j=1,jmax
             read (x(j,i),1001) iar,r1,(ic1(k),k=1,3)
             read (y(j,i),1002) r2
             aw=0
             fw=0
             do k=1,6
                aw=aw+iar(k)*a0(k)
                fw=fw+iar(k)*f(k)
             enddo
             arg(j,i)=aw
             freq(j,i)=fw
             freq2(j,i)=iar(3)+iar(4)+iar(5)
             r1=r1+ic1(1)*dnun+ic1(2)*dgam+ic1(3)*de
             r2=r2
             if (i.eq.1) then
                cs(j,i)=r2*1.d-3
                cc(j,i)=r1*1.d-3
             else
                cs(j,i)=r1*1.d-3
                cc(j,i)=r2*1.d-3
             endif
          enddo
       enddo
!
1001   format (6i3,f14.4,3i9)
1002   format (f10.4)
!
!      *********************************************************
!      * Transformation of the series from ESADE for velocity  *
!      *********************************************************
       do i=1,3
          jmax=nbv(i)
          do j=1,jmax
             read (v(j,i),2001) iar,r1,(ic1(k),k=1,3)
             read (w(j,i),2002) r2
             aw=0
             fw=0
             do k=1,6
                aw=aw+iar(k)*a0(k)
                fw=fw+iar(k)*f(k)
             enddo
             argv(j,i)=aw
             freqv(j,i)=fw
             frev2(j,i)=iar(3)+iar(4)+iar(5)
             r1=r1+ic1(1)*dnun+ic1(2)*dgam+ic1(3)*de
             r2=r2
             if (i.ne.1) then
                cvs(j,i)=r2*1.d-3
                cvc(j,i)=r1*1.d-3
             else
                cvs(j,i)=r1*1.d-3
                cvc(j,i)=r2*1.d-3
             endif
          enddo
       enddo
!
2001   format (6i3,f15.3,3i10)
2002   format (f11.3)
!
       return
       end
